package com.xique.door.controller;

import com.xique.common.core.utils.poi.ExcelUtil;
import com.xique.common.core.web.controller.BaseController;
import com.xique.common.core.web.domain.AjaxResult;
import com.xique.common.core.web.page.TableDataInfo;
import com.xique.common.log.annotation.Log;
import com.xique.common.log.enums.BusinessType;
import com.xique.common.security.annotation.PreAuthorize;
import com.xique.door.bean.domain.DCardHouse;
import com.xique.door.service.IDCardHouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * cardHouseController
 *
 * @author caogq
 * @date 2022-03-08
 */
@Controller
@RequestMapping("/oms/cardHouse")
public class DCardHouseController extends BaseController {


    @Autowired
    private IDCardHouseService dCardHouseService;

    /**
     * 查询cardHouse列表
     */
    @PreAuthorize(hasPermi = "oms:cardHouse:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DCardHouse dCardHouse) {
        startPage();
        List<DCardHouse> list = dCardHouseService.selectDCardHouseList(dCardHouse);
        return getDataTable(list);
    }


    /**
     * 新增保存cardHouse
     */
    @PreAuthorize(hasPermi = "oms:cardHouse:add")
    @Log(title = "cardHouse", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DCardHouse dCardHouse) {
        return toAjax(dCardHouseService.insertDCardHouse(dCardHouse));
    }


    /**
     * 修改保存cardHouse
     */
    @PreAuthorize(hasPermi = "oms:cardHouse:edit")
    @Log(title = "cardHouse", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DCardHouse dCardHouse) {
        return toAjax(dCardHouseService.updateDCardHouse(dCardHouse));
    }

    /**
     * 删除cardHouse
     */
    @PreAuthorize(hasPermi = "oms:cardHouse:remove")
    @Log(title = "cardHouse", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(dCardHouseService.deleteDCardHouseByIds(ids));
    }
}
